Expand description
ANSI Escape Sequences provider & parser
Sequences provider
The anes
crate provides ANSI escape sequences you can use to control the terminal
cursor (show, hide, …), colors (foreground, background), display attributes (bold, …)
and many others.
Every sequence implements the standard library Display
trait. It means that these sequences can be used in macros like
format!
or
write!
.
Ask if you need more sequences or use the sequence!
macro to create
your own sequences.
Terminal Support
Not all ANSI escape sequences are supported by all terminals. You can use the interactive-test to test them.
Examples
Retrieve the sequence as a String
:
use anes::SaveCursorPosition;
let string = format!("{}", SaveCursorPosition);
assert_eq!(&string, "\x1B7");
Execute the sequence on the standard output:
use std::io::{Result, Write};
use anes::execute;
fn main() -> Result<()> {
let mut stdout = std::io::stdout();
execute!(&mut stdout, anes::ResetAttributes)
}
Sequences parser
Parser isn’t available with default features. You have to enable parser
feature if you’d like to use it.
You can learn more about this feature in the parser
module documentation.
Modules
- An ANSI escape sequence parser module.
Macros
- Creates a control sequence.
- Creates an escape sequence.
- Executes ANSI escape sequence(s).
- Queues ANSI escape sequence(s).
- Creates an ANSI sequence.
- Creates a select graphic rendition sequence.
Structs
- Disables the cursor blinking.
- Tells the terminal to stop reporting mouse events.
- Enables the cursor blinking.
- Tells the terminal to start reporting mouse events.
- Hides the cursor.
- Moves the cursor down by the given number of rows.
- Moves the cursor left by the given number of columns.
- Moves the cursor right by the given number of columns.
- Moves the cursor to the given location (column, row).
- Moves the cursor to the given column.
- Moves the cursor to beginning of line the given number of lines down.
- Moves the cursor to beginning of line the given number of lines up.
- Moves the cursor up by the given number of rows.
- Asks for the current cursor position.
- Resets all attributes.
- Resizes the text area to the given width and height in characters.
- Restores the cursor position.
- Saves the cursor position.
- Scrolls down by the given number of rows.
- Scrolls up by the given number of rows.
- Sets the display attribute.
- Sets the background color.
- Sets the foreground color.
- Shows the cursor.
- Switches to the alternate buffer.
- Switches to the normal buffer.
Enums
- A display attribute.
- Clears part of the buffer.
- Clears part of the line.
- A color.